package main

import (
	"github.com/nsqio/go-nsq"
	"log"
)

type NsqMsg struct {
	RoomId string
	Msg []byte
}

var producer *nsq.Producer


func init() {
	config := nsq.NewConfig()
	newProducer, err := nsq.NewProducer("127.0.0.1:4150", config)
	if err != nil {
		log.Fatal(err)
	}
	producer = newProducer
}

func NsqSend(topic string, msg []byte)  {
	// Synchronously publish a single message to the specified topic.
	// Messages can also be sent asynchronously and/or in batches.
	err := producer.Publish(topic, msg)
	if err != nil {
		log.Fatal(err)
	}
}

